package com.biostime.qdingding.modules.qd.service;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.biostime.qdingding.modules.excel.MemberExcel;
import com.biostime.qdingding.modules.excel.OperateExcel;
import com.biostime.qdingding.modules.excel.OrderExcel;
import com.biostime.qdingding.modules.excel.SignedExcel;
import com.biostime.qdingding.modules.qd.dao.StatExportExcelDao;
import com.biostime.qdingding.modules.qd.entity.Center;
import com.biostime.qdingding.modules.qd.entity.CourseOrder;
import com.biostime.qdingding.modules.sys.utils.UserUtils;

/**
 * StatExportExcelService
 * 
 * @author king
 * @version 2016-02-25
 */
@Service
@Transactional(readOnly = true)
public class StatExportExcelService {
	
	@Autowired
	protected StatExportExcelDao dao;
	
	public List<MemberExcel> memberExport(){
		Center center = UserUtils.getCenter();
		
		return dao.memberExport(center == null ? "" : center.getId());
	}
	
	public List<OperateExcel> centerExport(){
		Center center = UserUtils.getCenter();
		
		return dao.centerExport(center == null ? "" : center.getId());
	}
	
	public List<SignedExcel> signedExport(String courseId){
		return dao.signedExport(courseId);
	}
	
	//获取多个signedExcel
	public List<List<SignedExcel>> signedExcelList(List<String> list){
		List<List<SignedExcel>> excelList = new ArrayList<List<SignedExcel>>();
		for(String courseId : list){
			excelList.add(dao.signedExport(courseId));
		}
		return excelList;
	}
	
	public List<String> getCourseIds(CourseOrder courseOrder){
		return dao.getCourseIds(courseOrder);
	}

	public List<OrderExcel> orderExport(OrderExcel order) {
		Center center = UserUtils.getCenter();
		
		if(order == null){
			order = new OrderExcel();
		}
		
		order.setCenterId(center.getId());
		
		return dao.orderExport(order); 
	}
	
}
